package com.tianhui.consignortwofei;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.fgs.common.api.CommonConfig;
import com.fgs.common.api.CommonConfigTwo;
import com.fgs.common.application.CommonApplication;
import com.fgs.common.other.crash.CrashHandler;
import com.tianhui.consignortwofei.api.ApiCommonConfig;
import com.tianhui.consignortwofei.api.ApiCommonConfigTwo;

/**
 * @author fgs
 * @date 2020/8/24
 * @description
 **/
public class MyApplication extends CommonApplication {


    @Override
    public void onCreate() {
        super.onCreate();
        CommonConfig.getInstance().init(this, new ApiCommonConfig());
        CommonConfigTwo.getInstance().init(this, new ApiCommonConfigTwo());
        mContext=this;
//        HotUpdateController.getInstance().init(this);


//        SDKInitializer.setAgreePrivacy(this, true);
//        //在使用SDK各组件之前初始化context信息，传入ApplicationContext
//        SDKInitializer.initialize(this);
//        //自4.3.0起，百度地图SDK所有接口均支持百度坐标和国测局坐标，用此方法设置您使用的坐标类型.
//        //包括BD09LL和GCJ02两种坐标，默认是BD09LL坐标。
//        SDKInitializer.setCoordType(CoordType.BD09LL);

        if (BuildConfig.DEBUG) {
            CrashHandler.getInstance().init(this);
        }
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        // 安装tinker
//        HotUpdateController.getInstance().installTinker();
    }

    public static void openActivity(Class pClass) {
        Intent intent = new Intent(getContext(), pClass);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getContext().startActivity(intent);

    }

    public static void openActivity(Class pClass, Bundle bundle) {
        Intent intent = new Intent(getContext(), pClass);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        getContext().startActivity(intent);

    }

    private static MyApplication mContext;
    public static MyApplication getInstance() {
        return mContext;
    }

}
